
import {IsString, IsNumber, IsBoolean, IsDate, IsOptional, IsEnum, IsNotEmpty} from 'class-validator';
import { ApiProperty, OmitType, IntersectionType } from '@nestjs/swagger';
import { PagingDto } from 'src/common/dto/index';
import { CharEnum } from 'src/common/enum/index';


export class BaseSchoolDto{
  @ApiProperty({required: false , description: '主键ID'})
  @IsOptional()
  @IsNumber()
  id?: number;

  @ApiProperty({required: true , description: '学校ID'})
  @IsOptional()
  schoolId: number;

  @ApiProperty({required: true , description: '专业ID'})
  @IsOptional()
  proId: number;

  @ApiProperty({enum: CharEnum, required: false , description: '删除标志'})
  @IsOptional()
  @IsString()
  delFlag?: string;

  @ApiProperty({enum: CharEnum, required: true , description: '状态'})
  @IsOptional()
  status: string;

  @ApiProperty({required: false , description: '创建者'})
  @IsOptional()
  @IsString()
  createBy?: string;

  @ApiProperty({required: false , description: '创建时间'})
  @IsOptional()
  @IsString()
  createTime?: string;

  @ApiProperty({required: false , description: '更新者'})
  @IsOptional()
  @IsString()
  updateBy?: string;

  @ApiProperty({required: false , description: '更新时间'})
  @IsOptional()
  @IsString()
  updateTime?: string;

  @ApiProperty({required: false , description: '备注'})
  @IsOptional()
  @IsString()
  remark?: string;

  @ApiProperty({required: true , description: '开设年份'})
  @IsString()
  @IsOptional()
  startDate: string;

}

export class CreateSchoolDto extends OmitType(BaseSchoolDto, [ 'id', 'delFlag', 'createBy', 'createTime']){
  @ApiProperty({required: true , description: '专业ID'})
  @IsNotEmpty({ message:"专业ID丢失"})
  proId: number;
}

export class UpdateSchoolDto extends OmitType(BaseSchoolDto, [ 'delFlag', 'createBy', 'createTime']){
  @ApiProperty({required: false , description: '主键ID'})
  @IsNotEmpty({ message:"主键不能为空"})
  @IsNumber()
  id: number;
}

export class QuerySchoolDto extends IntersectionType( BaseSchoolDto, PagingDto){}

export class ListSchoolDto  extends OmitType(BaseSchoolDto, [ 'delFlag', 'updateBy', 'updateTime']) {}
